package com.xiaoyu.lingdian.controller;

import java.util.Date;
import com.xiaoyu.lingdian.tool.StringUtil;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import com.xiaoyu.lingdian.tool.out.ResultMessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import com.xiaoyu.lingdian.controller.BaseController;
import com.xiaoyu.lingdian.entity.CoreTeam;
import com.xiaoyu.lingdian.service.CoreTeamService;
import com.xiaoyu.lingdian.vo.CoreTeamVO;

@Controller
@RequestMapping(value="/coreTeam")
public class CoreTeamController extends BaseController {

	/**
	* CoreTeam表
	*/
	@Autowired
	private CoreTeamService coreTeamService;
	
	/**
	* 修改
	*
	* @param crtamUuid 标识UUID
	* @param crtamContent 内容
	* @return
	*/
	@RequestMapping(value="/update/coreTeam", method=RequestMethod.POST)
	public void updateCoreTeam (String crtamUuid, String crtamContent, HttpServletResponse response) {
		logger.info("[CoreTeamController]:begin updateCoreTeam");
		if (StringUtil.isEmpty(crtamUuid)) {
			writeAjaxJSONResponse(ResultMessageBuilder.build(false, -1, "[标识UUID]不能为空!"), response);
			return;
		}
		CoreTeam coreTeam = new CoreTeam();
		coreTeam.setCrtamUuid(crtamUuid);
		coreTeam.setCrtamContent(crtamContent);
		coreTeam.setCrtamUdate(new Date());

		coreTeamService.updateCoreTeam(coreTeam);

		writeAjaxJSONResponse(ResultMessageBuilder.build(true, 1, "修改成功!"),response);
		logger.info("[CoreTeamController]:end updateCoreTeam");

	}

	/**
	* 获取单个
	*
	* @param crtamUuid 标识UUID
	* @return
	*/
	@RequestMapping(value="/views", method=RequestMethod.POST)
	public void viewsCoreTeam (String crtamUuid, HttpServletResponse response) {
		logger.info("[CoreTeamController]:begin viewsCoreTeam");
		if (StringUtil.isEmpty(crtamUuid)) {
			writeAjaxJSONResponse(ResultMessageBuilder.build(false, -1, "[标识UUID]不能为空!"), response);
			return;
		}
		CoreTeam coreTeam = new CoreTeam();
		coreTeam.setCrtamUuid(crtamUuid);

		coreTeam = coreTeamService.getCoreTeam(coreTeam);

		CoreTeamVO coreTeamVO = new CoreTeamVO();
		coreTeamVO.convertPOToVO(coreTeam);
		writeAjaxJSONResponse(ResultMessageBuilder.build(true, 1, "获取单个信息成功", coreTeamVO), response);
		logger.info("[CoreTeamController]:end viewsCoreTeam");

	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}